<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>



<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="embroot.css">
<TITLE>
Creating an ECLiPSe context
</TITLE>
</HEAD>
<BODY >
<A HREF="embroot004.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="embroot003.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot006.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>

<H2 CLASS="section"><A NAME="htoc8">2.2</A>&nbsp;&nbsp;Creating an ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> context</H2><UL>
<LI><A HREF="embroot005.html#toc5">Initialisation</A>
</UL>


ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> runs as a special thread (we will call it ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> engine) within
your application,
maintaining its own execution state. This section is about when and
how to initialise it. There are parameters to be applied before
initialisation, but these are usually acceptable. These parameters are
described in Appendix&nbsp;<A HREF="embroot064.html#chapecoptions">A</A>.<BR>
<BR>
Although it is useful to think of ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> as a thread, it is not an
<A NAME="@default9"></A>
operating system thread, but is rather implemented as a set of C
functions that maintain some state. This state is the complete
execution state of the ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> engine, its stack of goals, its
success and failure continuations and its global stack of all
constructed data.<BR>
<BR>
At particular points during its execution ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> will yield control
back to the C level. This is implemented by returning from a function.
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> can then be restarted from the exact point it left off. This
is implemented by a function call.<BR>
<BR>
<A NAME="toc5"></A>
<H3 CLASS="subsection"><A NAME="htoc9">2.2.1</A>&nbsp;&nbsp;Initialisation</H3>
You initialise ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> by calling the parameterless function
<A NAME="@default10"></A>
<PRE CLASS="verbatim">
    int ec_init();
</PRE>
A process should do this just once. <CODE>ec_init</CODE> returns 0 on success or
-1 if an error occurred. It is possible to influence the initialisation of
ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> by setting initialisation options as described in
Appendix&nbsp;<A HREF="embroot064.html#chapecoptions">A</A>.<BR>
<BR>
None of the functions of the interface work before this initialisation. In
particular in C++, if you use static variables which are
constructed by calling ECL<SUP><I>i</I></SUP>PS<SUP><I>e</I></SUP> functions you must arrange for the
initialisation to occur before the constructors are called.<BR>
<BR>
<HR>
<A HREF="embroot004.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="embroot003.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="embroot006.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
